{% extends 'base.html' %}
{% block title %}
    <a class="navbar-brand" href="#"> 员工加班记录 </a>
{% endblock %}
{% block content %}
{# 使用 length 过滤器获取 staffs 变量的长度 #}
    {% if current_user.has_role('Admin') or current_user.has_role('Root') %}

    {% endif %}
    {% if current_user.has_role('Admin') or current_user.has_role('Root') %}
    <div class="content">
        <h4 class="title">员工加班信息</h4>
        <div class="toolbar">

            <!--        Here you can write extra buttons/actions for the toolbar              -->
            <form method="post">
                查询方式
                <select name="info" required>
                    <option value="departmentID">部门编号</option>
                    <option value="departmentname">部门名称</option>
                </select>
                <input type="text" name="date" autocomplete="off" required>
                <input type="submit" name="submit" value="查询">
            </form>

        </div>
        <div class="material-datatables">
            <table id="datatables" class="table table-striped table-no-bordered table-hover"
                   style="width:100%;cellspacing:0">
                <thead>
                <tr>
                    <th>编号</th>
                    <th align="center">部门</th>
                    <th class="disabled-sorting" align="center">操作</th>
                </tr>
                </thead>

                <tbody>
                {% if info == 'departmentID' or info == 'departmentname' %}
                <tr>
                    <td>{{ departments.departmentID }}</td>
                    <td>{{ departments.departmentname }}</td>
                    <td>
                    <a href="{{ url_for('staff_overtime',departmentID=departments.departmentID) }}"
                       class="btn btn-simple btn-info btn-icon like">打卡记录</a>
                    </td>
                </tr>
                {% else %}
                    {% for department in departments %}
                    <tr>
                        <td>{{ department.departmentID }}</td>
                        <td>{{ department.departmentname }}</td>
                        <td >
                            <a href="{{ url_for('staff_overtime',departmentID=department.departmentID) }}" class="btn btn-simple btn-info btn-icon like">加班记录</a>
                        </td>
                    </tr>
                    {% endfor %}
                {% endif %}
                </tbody>

            </table>
        </div>
    </div>
    {% elif current_user.has_role('User') %}
    <div class="material-datatables">
        <table id="datatables" class="table table-striped table-no-bordered table-hover"
               style="width:100%;cellspacing:0">
            <thead>
            <tr>
                <th>编号</th>
                <th>部门</th>
                <th class="disabled-sorting">操作</th>
            </tr>
            </thead>

            <tbody>
            <tr>
                <td>{{ departments.departmentID }}</td>
                <td>{{ departments.departmentname }}</td>
                <td>
                    <a href="{{ url_for('staff_overtime',departmentID=departments.departmentID) }}"
                                   class="btn btn-simple btn-info btn-icon like">加班记录</a>
                </td>
            </tr>
            </tbody>

        </table>
    </div>
    {% endif %}
{% endblock %}